<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>
        <ui:composition template="./templates/principalTemplate.xhtml">
            <ui:define name="left"></ui:define>
            <ui:define name="content">
                <div id="login" class="center_content">
                    <h:form>

                        <f:metadata>  
                            <f:event type="preRenderView" listener="#{login.eliminaDatosLogin()}"></f:event>  
                        </f:metadata> 

                        <p:panel id="panel" header="LogIn" style="width: 650px;">
                            <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />

                            <h:panelGrid columns="3" cellpadding="5" style="padding: 8%">
                                <p:outputLabel for="txtUsuario" value="Usuario"/>
                                <p:inputText id="txtUsuario"  label="Usuario" required="true" value="#{login.usuario}">
                                    <f:validateRegex 
                                        pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                    <f:validateLength maximum="50" />
                                </p:inputText>
                                <p:message for="txtUsuario" />

                                <p:outputLabel for="txtContrasena" value="Contraseña"/>
                                <p:password id="txtContrasena"  label="Contraseña" required="true" 
                                            value="#{login.contrasena}" feedback="false" />
                                <p:message for="txtContrasena" />

                                <p:commandButton id="btnEntrar" value="Entrar" ajax="false" actionListener="#{login.entrar()}" />
                                <p:commandButton id="btnCancelar" value="Cancelar" ajax="false" />
                                <h:panelGroup />
                                <h:link outcome="/faces/usuario/crearUsuario" value="Registrar"/>

                            </h:panelGrid>
                        </p:panel>
                    </h:form>
                </div>
            </ui:define>
        </ui:composition>
    </body>





</html>
